package com.ylfstu.Poly_.objectpoly;

public class PolyObject {
    public static void main(String[] args) {

        //animal 编译类型是 Animal，运行类型是Dog
        Animal animal = new Dog();
        animal.cry();//因为运行时，执行到该行时，animal运行类型是Dog，所以cry就是Dog的cry

        //animal 编译类型是 Animal，运行类型是Cat
        animal = new Cat();
        animal.cry();

    }
}
